<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String province = "";
String city = "";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;hidden;margin:0;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=wPZMAIuRGrD8kGVjT1eEAUT1"></script>

<title>添加普通标注点</title>
</head>
<body>
<div id="allmap"></div>
<div>
<script type="text/javascript">
	var i = 0;
	var arr0 = [],arr1 = [],arr2 = [],arr3 = [];
</script>
	<c:forEach items="${cities}" var="c" varStatus="ind">
		<input type="hidden" id="${ind.index+300}" value="${c.id}"/>
		<input type="hidden" id="${ind.index}" value="${c.latitude}"/>
		<input type="hidden" id="${ind.index+100}" value="${c.longitude}"/>
		<input type="hidden" id="${ind.index+200}" value="${c.name}"/>
		<label id="lb">t${ind.index}</label>
		<script>
			arr0[i] = document.getElementById(i+300).value;
			arr1[i] = document.getElementById(i).value;
			arr2[i] = document.getElementById(i+100).value;
			arr3[i] = document.getElementById(i+200).value;
//			alert(arr1[i]+":"+arr2[i]+""+arr3[i]);
			i++;
		</script>
	</c:forEach>
</div>
</body>
</html>

<script type="text/javascript">
	alert(1);
// 百度地图API功能
var map = new BMap.Map("allmap");
//var t = document.getElementById("t").value;
//var g = document.getElementById("g").value;
map.centerAndZoom(new BMap.Point(116.404, 39.915), 5);
//map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);

for(var i = 0;i<arr1.length;i++){
	var marker1 = new BMap.Marker(new BMap.Point(arr1[i], arr2[i]));  // 创建标注
	map.addOverlay(marker1);              // 将标注添加到地图中
	//创建信息窗口
//	var infoWindow1 = new BMap.InfoWindow(arr3[i]);
	alert(arr3[i]+"id:"+arr0[i]);
//	marker1.addEventListener("click", function(){this.openInfoWindow(new BMap.InfoWindow(arr3[i]));});
//	var txt ='<a href='#'>'+arr3[i]+'</a>';
	var txt = "<a href='${pageContext.request.contextPath}/city/cityDetail.do?id="+arr0[i]+"'>"+arr3[i]+"</a>";
	addInfo(txt,marker1);
}
function addInfo(txt,marker){
    var infoWindow = new BMap.InfoWindow(txt);
    marker.addEventListener("click", function(){this.openInfoWindow(infoWindow);});  
}

//创建小狐狸
//var pt = new BMap.Point(116.417, 39.909);
//var myIcon = new BMap.Icon("fox.gif", new BMap.Size(300,157));
//var marker2 = new BMap.Marker(pt,{icon:myIcon});  // 创建标注
//map.addOverlay(marker2);              // 将标注添加到地图中

//让小狐狸说话（创建信息窗口）
//var infoWindow2 = new BMap.InfoWindow("<p style='font-size:18px;'>哈哈，你看见我啦！我可不常出现哦</p><p style='font-size:14px;'>赶快查看源代码，看看我是如何添加上来的！</p>");
//marker2.addEventListener("click", function(){this.openInfoWindow(infoWindow2);});
</script>
